package com.ray.friendslist.content.provider;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.ContentValues;
import android.net.Uri;

import com.ray.friendslist.content.contract.FriendsContract;
import com.ray.friendslist.content.provider.common.CommonProvider;

public class FriendsProvider extends CommonProvider {

	@Override
	protected String getTableName() {
		return FriendsContract.FriendsColumns.TABLE_NAME;
	}

	@Override
	public ContentValues getContentValues(JSONObject jsonObject)
			throws JSONException {
		ContentValues values = new ContentValues();
		values.put(FriendsContract.FriendsColumns.COLOUMNS[0],
				jsonObject.getString("uid"));
		values.put(
				FriendsContract.FriendsColumns.COLOUMNS[1],
				jsonObject.getString("first_name") + " "
						+ jsonObject.getString("last_name"));
		values.put(FriendsContract.FriendsColumns.COLOUMNS[2],
				jsonObject.getString("photo_medium"));
		values.put(FriendsContract.FriendsColumns.COLOUMNS[3],
				jsonObject.getString("photo_big"));
		return values;
	}

	@Override
	public String getContentType() {
		return FriendsContract.FriendsColumns.CONTENT_TYPE;
	}

	@Override
	public String[] getColoumns() {
		return FriendsContract.FriendsColumns.COLOUMNS;
	}

	@Override
	protected String getOrderBy() {
		return FriendsContract.FriendsColumns.VK_FRIEND_NAME;
	}

	@Override
	protected Uri getContentURI() {
		return FriendsContract.FriendsColumns.CONTENT_URI;
	}

}